//
//  WMTool.m
//  witMorning
//
//  Created by Mac mini on 2018/1/3.
//  Copyright © 2018年 zt. All rights reserved.
//

#import "WMTool.h"

@implementation WMTool


+(NSString *)currrentWithFormatterStyle:(NSString *)style{
    NSDate *date = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:style];
    
    NSString *str = [formatter stringFromDate:date];
    return str;
}

+(NSArray *)daysOfCurrentMonth{
     NSInteger y = [[WMTool currrentWithFormatterStyle:@"yyyy"] integerValue];
    NSInteger m = [[WMTool currrentWithFormatterStyle:@"MM"] integerValue];
    NSInteger d = [[WMTool currrentWithFormatterStyle:@"dd"] integerValue];
    NSInteger days = 0;
    if (m == 1||m==3||m==5||m==7||m==8||m==10||m==12) {
        days = 31;
    }else if(m==2){
        if (y%4>0) {
            days = 28;
        }else{
            days = 29;
        }
    }else{
        days = 30;
    }
    
    NSMutableArray *arr = [NSMutableArray arrayWithCapacity:0];
    
    for (NSInteger i = d; i<days+1; i++) {
        [arr addObject:[NSString stringWithFormat:@"%ld",i]];
    }
    return arr;
}

@end
